1. Technical Field
The present invention relates to assembly language programming in general, and in particular to a pre-processor for processing assembly language source code. Still more particularly, the present invention relates to an embedded pre-processor with dynamic macro forms.
2. Description of the Related Art
For a pre-processor to work well with an assembler, the pre-processor has to be able to mimic most, if not all, basic language statements within the assembler. An assembler typically has two basic macro forms, namely, the function call macro form and the opcode macro form. The function call macro form such as                func(arga,argb)resembles a function call that is shared by almost all high-level languages. The opcode macro form such as        opcode arg1,arg2behaves like a function call in many ways, except the arguments are not surrounded by parentheses. Generally speaking, the function call macro form dominates most modem high-level programming languages and the opcode macro form dominates most assembly programming languages.        
It is difficult to write a macro language grammar for a grammar that does not surround its function arguments with parentheses. Such difficulty results in most modern pre-processors, typified by C pre-processors and M4 pre-processors, being designed to favor the function call macro form. As such, most modem pre-processors are ill-suited for processing assembly language source code, and any attempt to extend a typical function call style pre-processor to accept the opcode macro form can lead to a very difficult problem. The problem is a macro form must be known before defining the language processing rules for the pre-processor, yet the macro form is not actually determined until the source code is being read by the pre-processor. In other words, a designer designing the pre-processor has to know what form the macro will be, but a programmer does not define the macro until the programmer's source code is being executed by the pre-processor.
For example, without any foreknowledge of the macro form, when the pre-processor encounters a statement like:                foo barthe pre-processor has a terrible problem to solve because the pre-processor does not know whether “foo” is just a macro without arguments or if “foo” takes arguments, and whether “bar” is one or two arguments (e.g., “bar”=“Alpha, Beta”). As indicated, the normal procedure to solve such a problem is to have some foreknowledge about “foo” and “bar.” However, the programmer defines “foo” and “bar” during the code execution within the pre-processor. Thus, the foreknowledge will have to be acquired at runtime.        
To complicate matters even further, a pre-processor for an assembler is commonly “embedded.” Unlike a pre-processor for C compilers, which can be run by itself, a pre-processor for an assembler prefers to use the assembler's built-in functions, and shares the same symbol table as the rest of the assembler while the source code is being assembled.
Consequently, it would be desirable to provide an improved embedded pre-processor that is capable of resolving the above-mentioned problem.